package ylg.com.cn.youtube.main.fragment_user;

import ylg.com.cn.youtube._data.User;
import ylg.com.cn.youtube._data.source.UserDataSource;
import ylg.com.cn.youtube._data.source.remote.UserRemoteDataSource;

/**
 * Created by MyPC on 2017/1/11.
 */
public class UserPagePresenter implements UserPageContract.Presenter {

    private final UserPageContract.View view;

    UserRemoteDataSource model;

    public UserPagePresenter(UserPageContract.View view, UserRemoteDataSource model) {
        this.view = view;
        this.model = model;
    }

    //登录的网络请求;
    @Override
    public void login(String name, String password) {
        view.onLoginProgress();
        model.login(name, password, new UserDataSource.LoginCallBack() {
            @Override
            public void onLoginSuccess(User user) {
                view.showUser(user);
            }

            @Override
            public void onLoginError(String message) {
                view.onLoginError(message);
            }
        });
    }

    @Override
    public void start() {

    }
}
